<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>default-event-rule-common</title>
  	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/jbox.jsp"%>
	<%@ include file="../include/table.jsp"%>
	
	<script type="text/javascript">
	$(function(){
		//加载grid
		var oTable=	$('#defaultEventRuleList').dataTable({
			"bProcessing": true, 
			"bServerSide": true,
			"sServerMethod": 'POST',
			"sAjaxSource":'${pageContext.request.contextPath}/event/default-event-rule!list.action',
			"bPaginate": true,
			"bSort": true,
			"bFilter":false,
			"bJQueryUI":false,
			"sPaginationType": "full_numbers",
			"sDom":'rt <"bottom"flpi>',
			"iDisplayLength":20,
			"aLengthMenu": [[20, 50, 100], [20, 50,100]],
			"aoColumns":[
				{"mDataProp":"op","":"center","bSortable": false},
				{"mDataProp":"resTypeName","bSortable": false},
				{"mDataProp":"eventTypeName","bSortable": false},
				{"mDataProp":"levelName"},
				{"mDataProp":"expr","bSortable": false},
				{"mDataProp":"status","fnCreatedCell":function(nTd, sData, oData, iRow, iCol){
					var imgSrc = oData.statusIndex==1?"collect_Enable.png":"collect_disable.png";
					$(nTd).html("<img width='16px' height='16px'src='../style/default/bsm/images/"+imgSrc+"' title='"+sData+"' />"+sData);
				}},
				{"mDataProp":"id","bVisible":false}
			], 
			 "oLanguage": { 
			 				"sLengthMenu": "每页 _MENU_ 条",
			 		 		"sZeroRecords": "  ",
							"sInfo": "当前从 _START_ 到 _END_ 条,共 _TOTAL_ 条记录", 
							"sInfoEmpty": "没有找到记录",
							"oPaginate":{"sFirst":"首页","sPrevious":"上一页","sNext":"下一页","sLast":"尾页"}	
			},
		    "fnServerParams":function(aoData){
		    	var resTypeName = $("#resTypeName").val();
		    	if(resTypeName!='')
		    	{
		    		aoData.push({'name':'resTypeName','value':resTypeName});
		    	}
		    	var eventTypeName = $("#eventTypeName").val();
		    	if(eventTypeName!='')
		    	{
		    		aoData.push({'name':'eventTypeName','value':eventTypeName});
		    	}
		    }
		});
	})
	function datagrid(){
		var oTable=	$('#defaultEventRuleList').dataTable();
		oTable._fnAjaxUpdate();
	}
	function stop(id){
		var submit = function (v, h, f) {
		    if (v == 'ok') {
		    	$.ajax({
		    		type : "POST",
		    		url : "${pageContext.request.contextPath}/event/default-event-rule!stop.action", //请求的action
		    		data : "id="+id, //传的参数
		    		dataType : 'json',
		    		success : function(data) { //结果
		    			window.setTimeout(function () { $.jBox.tip("全局禁用成功!", 'success'); }, 100);
						datagrid();
		    		}
		    	});
		    }
		    else if (v == 'cancel') {
		    }
		    return true; 
		};
		getTopWin(window).jBox.confirm("确定要全局禁用此条默认事件规则吗？禁用后，所有资源下的此条默认规则规则都将不再显示", "提示", submit);
	}
	function start(id){
		var submit = function (v, h, f) {
		    if (v == 'ok') {
		    	$.ajax({
		    		type : "POST",
		    		url : "${pageContext.request.contextPath}/event/default-event-rule!start.action", //请求的action
		    		data : "id="+id, //传的参数
		    		dataType : 'json',
		    		success : function(data) { //结果
		    			window.setTimeout(function () { $.jBox.tip("全局启用成功!", 'success'); }, 100);
						datagrid();
		    		}
		    	});
		    }
		    else if (v == 'cancel') {
		    }
		    return true; 
		};
		getTopWin(window).jBox.confirm("确定要全局启用此条默认事件规则吗？", "提示", submit);
	}
	function edit(id){
		window.location.href="${pageContext.request.contextPath}/event/default-event-rule!input.action?id="+id;
	}
	function search(){
		var oTable=	$('#defaultEventRuleList').dataTable();
		oTable.fnPageChange("first",true);
	}
  	</script>
  </head>
  
  <body>
  	<div class="searchFormStyle">
  		<label>资源类别：</label><input type="text" id="resTypeName" name="resTypeName"/>
  		<label>事件类别：</label><input type="text" id="eventTypeName" name="eventTypeName"/>
  		<input type="button" onclick="search();" value="查询" class="searchFormButtonStyle">
  	</div>
  	<h2 class="title-h2" style="margin-top:0; ">默认事件规则列表</h2>
    <table id="defaultEventRuleList" width="100%" cellpadding="0" cellspacing="0" border="0" class="display">
		<thead>
			<tr>
				<th width="5%">操作</th>
				<th width="20%">资源类别</th>
				<th width="20%">事件类别</th>
				<th width="10%">事件级别</th>
				<th width="35%">事件表达式</th>
				<th width="10%">状态</th>
			</tr>
		</thead>
	</table>
  </body>
</html>
